<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>

<div id="main_mdata_list" class="easyui-layout" fit="true">
    <div region="north" style="padding:0px;border:0px">
         <table style="width: 100%;" cellpadding="0" cellspacing="1"  border="0" class="formtable" align="center">
	       <tr height="40" >
				<td>
				    <label style="padding:2px;"> 班组  </label>
				    <select name="bzId" id="bzId" style="margin-left:5px;width:160px;"  onchange="setCheckerName(this.value,'');">
					         <option value="">请选择</option>	
					         <!-- 遍历班组-->			
			                 <c:forEach var="team" items="${teamLst }" >                      
					             <option value="${team.bzId }">${team.bzName }</option>
					         </c:forEach>
				    </select>
				    
				    <label class="Validform_label" style="width:140px;"><span style="color:red;">*</span> 用检员: </label> 
					<select name="checkerName" id="checkerName" style="width:160px;height:30px;" value="">
					       <option value="" >请选择</option>
		                  
			        </select>
				   
				   <label style="padding:2px;"> 月份  </label>
				   <input class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM'})" style="width: 180px;" id="createMonth"
						       name="createMonth" ignore="ignore" value="">
	                <a href="#" class="easyui-linkbutton"  plain="true" iconCls="icon-search"  style="margin-left:5px;" onclick="myquery();" >查 询</a>
	                <a href="#" class="easyui-linkbutton"  plain="true" iconCls="icon-cancel"  style="margin-left:5px;" onclick="myreset();" >清 空</a>
				</td>
				
			</tr>
		 </table>
	   </div>
    <div region="center" style="padding:0px;border:0px;">
        <t:datagrid name="mdataList" title="月数据维护" actionUrl="homeController.do?mdataGrid" idField="id" treegrid="false" pagination="true"  sortOrder="desc" sortName="createMonth" onLoadSuccess="">
            <t:dgCol title="唯一标识" field="id"  width="30" hidden="true"></t:dgCol>
            <t:dgCol title="月份" field="createMonth"  width="100" ></t:dgCol>
            <t:dgCol title="班组名称" field="bzName" width="100" ></t:dgCol>
            <t:dgCol title="用检员" field="checkerName" width="100" ></t:dgCol>
            <t:dgCol title="当月巡检户数" field="inspections" width="100"></t:dgCol>
            <t:dgCol title="计划巡检户数" field="planInspections" width="100"></t:dgCol>
            <t:dgCol title="已参与电力保障次数" field="powerGuarants" width="100"></t:dgCol>
            <t:dgCol title="当月应急抢修次数" field="emergencyRepairs" width="100"></t:dgCol>
            <t:dgCol title="预结算比例(%)" field="settleProportion" width="100"></t:dgCol>
            <t:dgCol title="common.operation" field="opt" width="50"></t:dgCol>
            <t:dgDelOpt url="homeController.do?delMdate&id={id}" title="删除"></t:dgDelOpt> 
            <t:dgToolBar title="新增" icon="icon-add" url="homeController.do?aouMdata" funname="add" height="530"></t:dgToolBar>
            <t:dgToolBar title="编辑" icon="icon-edit" url="homeController.do?aouMdata" funname="update" height="530"></t:dgToolBar>
            <t:dgToolBar title="导入" icon="icon-put" funname="ImportXls"></t:dgToolBar>
            <t:dgToolBar title="templateDownload" icon="icon-putout" funname="ExportXlsByT"></t:dgToolBar>
        </t:datagrid>
    </div>
    
</div>

<script type="text/javascript">
    $(function() {
        
    });
    
    function myquery(){
		 //班组编号
	    var bzId = $('#bzId').val();
	     //用检员
	    var checkerName = $('#checkerName').val();
		 //月份
	    var createMonth = $('#createMonth').val();		
		
		$('#mdataList').datagrid({
			queryParams: {
				bzId: bzId,
				createMonth: createMonth,
				checkerName:checkerName
			}
		});

	}
    
    function myreset(){
		$('#bzId').val('');
		$('#createMonth').val('');
		$('#checkerName').val('');
	}
    
    function setCheckerName(bzId,checkerName){	
    	
		 $.getJSON('homeController.do?getCheckersByBzId&bzId='+bzId, function (data) {  
           if (data.success) {   
          	   $("#checkerName").empty(); 
          	   $("#checkerName").append("<option value=''>请选择</option>"); 
          	   $.each(data.obj,function(n,value) { 
          		   var option = '';
          		   var cName = value.checkerName.trim();
          		   
          		   if(checkerName==cName){    
          			   option = $("<option selected>").val(cName).text(cName); 
          		   }else{
          			   option = $("<option>").val(cName).text(cName); 
          		   }
          		   
              	   $("#checkerName").append(option); 
          	   });
          	  
           } else {  
               alert('提示', data.msg);  
           }  
       });
	}
    
	//模板下载
	function ExportXlsByT() {
		JeecgExcelExport("homeController.do?exportXlsByMdataT","mdataList");
		
	}
	
	//导入
	function ImportXls() {
		$.dialog.setting.zIndex = getzIndex(true);
	    openuploadwin('班级重点工作日数据导入', 'homeController.do?uploadMonthForm', "mdataList");
	}
</script>
